package com.dz.Incubator.service.impl;

import com.dz.Incubator.dao.SysUserRoleDao;
import com.dz.Incubator.entity.SysUserRoleEntity;
import com.dz.Incubator.service.SysUserRoleService;
import com.dz.Incubator.config.Pagination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {

	private static final Logger logger = LoggerFactory.getLogger(SysUserRoleService.class);

    @Autowired
    private SysUserRoleDao sysUserRoleDao;

    @Override
    public SysUserRoleEntity insert(SysUserRoleEntity sysUserRoleEntity) {
        sysUserRoleDao.insert(sysUserRoleEntity);
        
        return sysUserRoleEntity;
    }

    @Override
    public SysUserRoleEntity update(SysUserRoleEntity sysUserRoleEntity) {
        sysUserRoleDao.update(sysUserRoleEntity);
        
        return sysUserRoleEntity;
    }

    @Override
    public Integer delete(Long id) {
        int ret = sysUserRoleDao.delete(id);
        return ret;
    }
    
    @Override
    public List<SysUserRoleEntity> find(Long[] ids) {
        List<SysUserRoleEntity> datas = sysUserRoleDao.find(ids);
        return datas;
    }

    @Override
    public SysUserRoleEntity get(Long id) {
        SysUserRoleEntity sysUserRoleEntity = sysUserRoleDao.get(id);
        return sysUserRoleEntity;
    }

    @Override
    public List<SysUserRoleEntity> findAll() {
    	List<SysUserRoleEntity> datas = sysUserRoleDao.findAll();
    	return datas;
    }
    
    @Override
    public Pagination  findByPagination(Pagination pagination) {
    	List<SysUserRoleEntity> datas = sysUserRoleDao.findByPagination(pagination);
    	pagination.setList(datas);
    	return pagination;
    }
	
	@Override
    public List<SysUserRoleEntity> insertBatch(List<SysUserRoleEntity> list) {
        int ret = sysUserRoleDao.insertBatch(list);
        return list;
    }
    
    @Override
    public List<SysUserRoleEntity> updateBatch(List<SysUserRoleEntity> list) {
        int ret = sysUserRoleDao.updateBatch(list);
        return list;
    }
    
    @Override
    public List<Long> deleteBatch(Long[] ids) {
        int ret = sysUserRoleDao.deleteBatch(ids);
        List<SysUserRoleEntity>  datas = sysUserRoleDao.find(ids);
        List<Long> list = new ArrayList<Long>();
        for (SysUserRoleEntity data : datas) {
        	list.add(data.getId());
        }
        return list;
    }
}